/**
 * 
 */
package com.nursery.student.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.nursery.student.dao.StudentInfoMapper;
import com.nursery.student.entity.StudentInfo;
import com.nursery.student.entity.StudentInfoExample;
import com.nursery.student.service.StudentInfoService;

@Service
public class StudentInfoServiceImpl implements StudentInfoService {

	@Autowired
	StudentInfoMapper studentInfoMapper;

	public Map<String, String> login(String cardNo, String password) {
		Map<String, String> map = new HashMap<>();
		if (StringUtils.isBlank(cardNo) || StringUtils.isBlank(password)) {
			map.put("status", "1");
		} else {
			StudentInfoExample example = new StudentInfoExample();
			StudentInfoExample.Criteria criteria = example.createCriteria();
			// 证件编号
			criteria.andCardNoEqualTo(cardNo);
			// 密码
			criteria.andPasswordEqualTo(password);
			Long l = studentInfoMapper.countByExample(example);
			if (l != null && l != 0) {
				map.put("status", "0");
			} else {
				map.put("status", "1");
			}
		}
		return map;
	}

	public List<StudentInfo> selectByExample(StudentInfoExample example) {
		return studentInfoMapper.selectByExample(example);
	}

	public void add(StudentInfo studentInfo) {
		studentInfoMapper.insertSelective(studentInfo);
	}

	public StudentInfo selectById(Integer id) {
		return studentInfoMapper.selectByPrimaryKey(id);
	}

	public void updateByPrimaryKeySelective(StudentInfo record) throws Exception {
		studentInfoMapper.updateByPrimaryKeySelective(record);
	}

	public void deleteByPrimaryKey(Integer id) throws Exception {
		studentInfoMapper.deleteByPrimaryKey(id);
	}

}
